Folium base
In [1]:
Copied!
# Uncomment below to run in Google Collab
# pip install ecospat
# Uncomment below to run in Google Collab
# pip install ecospat
Basic static mapping functions in ecospat¶
In [2]:
Copied!
import ecospat.foliummap as ecospat_foliummap
import ecospat.foliummap as ecospat_foliummap
In [3]:
Copied!
# A simple map with different basemap options and layer control
simple_folium = ecospat_foliummap.Map(center=[20, 0], zoom=2, tiles="OpenStreetMap")
simple_folium.add_basemap("OpenTopoMap")
simple_folium.add_layer_control()
simple_folium
# A simple map with different basemap options and layer control
simple_folium = ecospat_foliummap.Map(center=[20, 0], zoom=2, tiles="OpenStreetMap")
simple_folium.add_basemap("OpenTopoMap")
simple_folium.add_layer_control()
simple_folium
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Advanced maps that display vector and raster data¶
Countries on a dark map¶
In [4]:
Copied!
advanced_folium = ecospat_foliummap.Map(
center=[20, 0], zoom=2, tiles="CartoDB dark_matter"
)
url = "https://github.com/opengeos/datasets/releases/download/world/countries.geojson"
advanced_folium.add_geojson(url, name="Countries")
advanced_folium.add_layer_control()
advanced_folium
advanced_folium = ecospat_foliummap.Map(
center=[20, 0], zoom=2, tiles="CartoDB dark_matter"
)
url = "https://github.com/opengeos/datasets/releases/download/world/countries.geojson"
advanced_folium.add_geojson(url, name="Countries")
advanced_folium.add_layer_control()
advanced_folium
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
World lakes from .shp¶
In [5]:
Copied!
world_lakes_folium = ecospat_foliummap.Map(
center=[39.8283, -98.5795], zoom=4, tiles="Esri.WorldImagery"
)
world_lakes_folium.add_shp_from_url(
"https://github.com/nvkelso/natural-earth-vector/blob/master/10m_physical/ne_10m_lakes",
name="Lakes of Europe",
)
world_lakes_folium.add_layer_control()
world_lakes_folium
world_lakes_folium = ecospat_foliummap.Map(
center=[39.8283, -98.5795], zoom=4, tiles="Esri.WorldImagery"
)
world_lakes_folium.add_shp_from_url(
"https://github.com/nvkelso/natural-earth-vector/blob/master/10m_physical/ne_10m_lakes",
name="Lakes of Europe",
)
world_lakes_folium.add_layer_control()
world_lakes_folium
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Split map with raster data¶
In [6]:
Copied!
new_map = ecospat_foliummap.Map(center=[40, -100], zoom=4)
# Add split map with two GeoTIFFs on the left and right
new_map.add_split_map(
left="https://raw.githubusercontent.com/kgjenkins/ophz/master/tif/ophz-us48.tif",
right="https://raw.githubusercontent.com/kgjenkins/ophz/master/tif/ophz-us48.tif",
colormap_left="viridis",
colormap_right="magma",
opacity_left=0.9,
opacity_right=0.8,
)
# Add the LayerControl to toggle layers independently
new_map.add_layer_control()
new_map
new_map = ecospat_foliummap.Map(center=[40, -100], zoom=4)
# Add split map with two GeoTIFFs on the left and right
new_map.add_split_map(
left="https://raw.githubusercontent.com/kgjenkins/ophz/master/tif/ophz-us48.tif",
right="https://raw.githubusercontent.com/kgjenkins/ophz/master/tif/ophz-us48.tif",
colormap_left="viridis",
colormap_right="magma",
opacity_left=0.9,
opacity_right=0.8,
)
# Add the LayerControl to toggle layers independently
new_map.add_layer_control()
new_map
Out[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook